const Koa = require("koa");

const app = new Koa(); // 创建app对象

// 中间件: path/method
app.use(async (ctx, next) => {
  if (ctx.path === "/users") {
    if (ctx.method === "GET") {
      ctx.body = "get users list";
    } else if (ctx.method === "POST") {
      ctx.body = "create user success";
    }
  } else if (ctx.path === "/home") {
    ctx.body = "home data list~";
  } else if (ctx.path === "/login") {
    ctx.body = "login success";
  }
});

app.listen(6000, () => {
  console.log("koa服务器启动成功~");
});
